package avicit.bdp.dgs.standard.dto;

import avicit.bdp.common.base.BaseDTO;
import avicit.bdp.core.enums.DataElementDataTypeEnum;
import avicit.bdp.core.enums.DataElementStandardTypeEnum;
import avicit.bdp.core.enums.DataStateEnum;
import avicit.platform6.core.annotation.log.FieldRemark;
import avicit.platform6.core.annotation.log.LogField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.apache.commons.lang3.StringUtils;

/**
 * @author mayi 数据标准-数据元历史记录
 */
@ApiModel(value = "DataElementHistoryDto", description = "数据元")
@Table(name = "bdp_dgs_data_element_history")
public class DataElementHistoryDto extends BaseDTO {

  private static final long serialVersionUID = 1L;

  /** 主键ID */
  @LogField
  @ApiModelProperty(value = "主键")
  @FieldRemark(column = "id", field = "id", name = "主键")
  @Column(name = "id")
  @avicit.platform6.core.annotation.log.Id
  @javax.persistence.Id
  private String id;

  /** 数据元ID */
  @LogField
  @ApiModelProperty(value = "数据元ID", name = "dataElementId")
  @FieldRemark(column = "data_element_id", field = "dataElementId", name = "数据元ID")
  private String dataElementId;

  /** 数据元版本 */
  @LogField
  @ApiModelProperty(value = "数据元版本", name = "dataElementVersion")
  @FieldRemark(column = "data_element_version", field = "dataElementVersion", name = "数据元版本")
  private String dataElementVersion;

  /** 所属分类 */
  @LogField
  @ApiModelProperty(value = "所属分类", name = "typeId")
  @FieldRemark(column = "type_id", field = "typeId", name = "所属分类")
  private String typeId;

  /** 标准编码 */
  @LogField
  @ApiModelProperty(value = "标准编码", name = "code")
  @FieldRemark(column = "code", field = "code", name = "标准编码")
  private String code;

  /** 中文名称 */
  @LogField
  @ApiModelProperty(value = "中文名称", name = "name")
  @FieldRemark(column = "name", field = "name", name = "中文名称")
  private String name;

  /** 英文名称 */
  @LogField
  @ApiModelProperty(value = "英文名称", name = "enName")
  @FieldRemark(column = "en_name", field = "enName", name = "英文名称")
  private String enName;

  /**
   * 状态
   *
   * @see DataStateEnum
   */
  @LogField
  @ApiModelProperty(value = "状态", name = "status")
  @FieldRemark(column = "status", field = "status", name = "状态")
  private Integer status;

  /**
   * 数据类型
   *
   * @see DataElementDataTypeEnum
   */
  @LogField
  @ApiModelProperty(value = "数据类型", name = "dataType")
  @FieldRemark(column = "data_type", field = "dataType", name = "数据类型")
  private Integer dataType;

  /**
   * 标准类型
   *
   * @see DataElementStandardTypeEnum
   */
  @LogField
  @ApiModelProperty(value = "标准类型", name = "standardType")
  @FieldRemark(column = "standard_type", field = "standardType", name = "标准类型")
  private Integer standardType;

  /** 标准来源 */
  @LogField
  @ApiModelProperty(value = "标准来源", name = "standardFrom")
  @FieldRemark(column = "standard_from", field = "standardFrom", name = "标准来源")
  private String standardFrom;

  /** 业务含义 */
  @LogField
  @ApiModelProperty(value = "业务含义", name = "businessMeaning")
  @FieldRemark(column = "business_meaning", field = "businessMeaning", name = "业务含义")
  private String businessMeaning;

  /** 长度 */
  @LogField
  @ApiModelProperty(value = "长度")
  @FieldRemark(column = "length", field = "length", name = "长度")
  private Integer length;

  /** 精度 */
  @LogField
  @ApiModelProperty(value = "精度")
  @FieldRemark(column = "decimal_precision", field = "decimalPrecision", name = "精度")
  private Integer decimalPrecision;

  /** 是否引用数据字典 */
  @LogField
  @ApiModelProperty(value = "是否引用数据字典")
  @FieldRemark(column = "quote_lookup_table", field = "quoteLookupTable", name = "是否引用数据字典")
  private Integer quoteLookupTable;

  /** 引用数据字典主键 */
  @LogField
  @ApiModelProperty(value = "引用数据字典主键", name = "lookupTableId")
  @FieldRemark(column = "lookup_table_id", field = "lookupTableId", name = "引用数据字典主键")
  private String lookupTableId;

  /** 是否非空 */
  @LogField
  @ApiModelProperty(value = "是否非空")
  @FieldRemark(column = "not_null", field = "notNull", name = "是否非空")
  private Integer notNull;

  /** 是否唯一 */
  @LogField
  @ApiModelProperty(value = "是否唯一")
  @FieldRemark(column = "unique_key", field = "uniqueKey", name = "是否唯一")
  private Integer uniqueKey;

  @ApiModelProperty(value = "状态")
  @Transient
  private String statusString;

  @ApiModelProperty(value = "数据类型", name = "dataTypeString")
  @Transient
  private String dataTypeString;

  @ApiModelProperty(value = "标准类型", name = "standardTypeString")
  @Transient
  private String standardTypeString;

  @ApiModelProperty(value = "分类名称", name = "typeName")
  @Transient
  private String typeName;

  @Transient
  private String lookupTableName;

  public String getId() {
    return id;
  }

  public void setId(String id) {
    this.id = id;
  }

  public String getDataElementId() {
    return dataElementId;
  }

  public void setDataElementId(String dataElementId) {
    this.dataElementId = dataElementId;
  }

  public String getTypeId() {
    return typeId;
  }

  public void setTypeId(String typeId) {
    this.typeId = typeId;
  }

  public String getCode() {
    return code;
  }

  public void setCode(String code) {
    this.code = code;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public String getEnName() {
    return enName;
  }

  public void setEnName(String enName) {
    this.enName = enName;
  }

  public Integer getStatus() {
    return status;
  }

  public void setStatus(Integer status) {
    this.status = status;
  }

  public Integer getDataType() {
    return dataType;
  }

  public void setDataType(Integer dataType) {
    this.dataType = dataType;
  }

  public Integer getStandardType() {
    return standardType;
  }

  public void setStandardType(Integer standardType) {
    this.standardType = standardType;
  }

  public String getStandardFrom() {
    return standardFrom;
  }

  public void setStandardFrom(String standardFrom) {
    this.standardFrom = standardFrom;
  }

  public String getBusinessMeaning() {
    return businessMeaning;
  }

  public void setBusinessMeaning(String businessMeaning) {
    this.businessMeaning = businessMeaning;
  }

  public Integer getLength() {
    return length;
  }

  public void setLength(Integer length) {
    this.length = length;
  }

  public Integer getDecimalPrecision() {
    return decimalPrecision;
  }

  public void setDecimalPrecision(Integer decimalPrecision) {
    this.decimalPrecision = decimalPrecision;
  }

  public Integer getQuoteLookupTable() {
    return quoteLookupTable;
  }

  public void setQuoteLookupTable(Integer quoteLookupTable) {
    this.quoteLookupTable = quoteLookupTable;
  }

  public String getLookupTableId() {
    return lookupTableId;
  }

  public void setLookupTableId(String lookupTableId) {
    this.lookupTableId = lookupTableId;
  }

  public Integer getNotNull() {
    return notNull;
  }

  public void setNotNull(Integer notNull) {
    this.notNull = notNull;
  }

  public Integer getUniqueKey() {
    return uniqueKey;
  }

  public void setUniqueKey(Integer uniquekey) {
    this.uniqueKey = uniquekey;
  }

  public String getStatusString() {
    return statusString;
  }

  public void setStatusString(String statusString) {
    this.statusString = statusString;
  }

  public String getDataTypeString() {
    return dataTypeString;
  }

  public void setDataTypeString(String dataTypeString) {
    this.dataTypeString = dataTypeString;
  }

  public String getStandardTypeString() {
    return standardTypeString;
  }

  public void setStandardTypeString(String standardTypeString) {
    this.standardTypeString = standardTypeString;
  }

  public String getDataElementVersion() {
    return dataElementVersion;
  }

  public void setDataElementVersion(String dataElementVersion) {
    this.dataElementVersion = dataElementVersion;
  }

  public String getTypeName() {
    return typeName;
  }

  public void setTypeName(String typeName) {
    this.typeName = typeName;
  }

  public String getLookupTableName() {
    return lookupTableName;
  }

  public void setLookupTableName(String lookupTableName) {
    this.lookupTableName = lookupTableName;
  }

  @Override
  public String getLogFormName() {
    if (StringUtils.isEmpty(super.logFormName)) {
      return "数据标准模块";
    } else {
      return super.logFormName;
    }
  }

  @Override
  public String getLogTitle() {
    if (StringUtils.isEmpty(super.logTitle)) {
      return "数据元历史版本";
    } else {
      return super.logTitle;
    }
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    DataElementHistoryDto that = (DataElementHistoryDto) o;
    return Objects.equals(getId(), that.getId())
        && Objects.equals(getDataElementId(), that.getDataElementId())
        && Objects.equals(getDataElementVersion(), that.getDataElementVersion())
        && Objects.equals(getTypeId(), that.getTypeId())
        && Objects.equals(getCode(), that.getCode())
        && Objects.equals(getName(), that.getName())
        && Objects.equals(getEnName(), that.getEnName())
        && Objects.equals(getStatus(), that.getStatus())
        && getDataType().equals(that.getDataType())
        && getStandardType().equals(that.getStandardType())
        && Objects.equals(getStandardFrom(), that.getStandardFrom())
        && Objects.equals(getBusinessMeaning(), that.getBusinessMeaning())
        && Objects.equals(getLength(), that.getLength())
        && Objects.equals(getDecimalPrecision(), that.getDecimalPrecision())
        && Objects.equals(getQuoteLookupTable(), that.getQuoteLookupTable())
        && Objects.equals(getLookupTableId(), that.getLookupTableId())
        && Objects.equals(getNotNull(), that.getNotNull())
        && Objects.equals(getUniqueKey(), that.getUniqueKey());
  }

  @Override
  public int hashCode() {
    return Objects.hash(
        getId(),
        getDataElementId(),
        getDataElementVersion(),
        getTypeId(),
        getCode(),
        getName(),
        getEnName(),
        getStatus(),
        getDataType(),
        getStandardType(),
        getStandardFrom(),
        getBusinessMeaning(),
        getLength(),
        getDecimalPrecision(),
        getQuoteLookupTable(),
        getLookupTableId(),
        getNotNull(),
        getUniqueKey());
  }
}
